package eqsolver;


import java.util.Observable;

public class ModelLinearEquation extends Observable implements IEquation, ISolver {

	private float[] param = new float[2];
	private int numberParam;

	@Override
	public void setEquation(int numberParam, float[] param) {
		if (param == null) {
			param = new float[2];
		}
		
		for (int i = 0; i < numberParam; i++) {
			this.param[i] = param[i];
			System.out.println(" da model linear "+param[i]);
		}
		
		this.numberParam = numberParam;
		//System.out.println(param[0]+" "+param[1]);
		//System.out.println(getSol());
		setChanged();
		notifyObservers();
		
	}
	
	public void solve() {
		//non c'è l'utilità adesso
	}

	public float[] getSol() {
		float a = param[0];
		float b = param[1];
		float[] x = new float[1];

		x[0] = -b / a;

		return x;
	}
	
	public float[] getParam() {
		return param;
	}

	public int getNumberParam() {
		return numberParam;
	}
}
